package com.sl.biz.modular.restapi.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.restapi.dao.entity.ApiEntityConfigDO;
import com.sl.biz.modular.restapi.dao.mapper.ApiEntityConfigMapper;
import com.sl.biz.modular.restapi.dao.service.ApiEntityConfigDaoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ApiEntityConfigDaoServiceImpl extends ServiceImpl<ApiEntityConfigMapper, ApiEntityConfigDO> implements ApiEntityConfigDaoService {


    @Override
    public ApiEntityConfigDO queryByApiId(String apiId) {
        LambdaQueryWrapper<ApiEntityConfigDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ApiEntityConfigDO::getApiId, apiId);
        return super.getOne(queryWrapper);
    }

    @Override
    public List<ApiEntityConfigDO> queryByVersionIdList(List<String> versionIdList) {
        LambdaQueryWrapper<ApiEntityConfigDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(ApiEntityConfigDO::getApiVersionId, versionIdList);
        return super.list(queryWrapper);
    }

    @Override
    public ApiEntityConfigDO queryByApiVersionId(String versionId) {
        LambdaQueryWrapper<ApiEntityConfigDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ApiEntityConfigDO::getApiVersionId, versionId);
        return super.getOne(queryWrapper);
    }

    @Override
    public Boolean removeByApiVersionConfigId(String apiVersionId) {
        LambdaQueryWrapper<ApiEntityConfigDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ApiEntityConfigDO::getApiVersionId, apiVersionId);
        return super.remove(queryWrapper);
    }
}
